package com.lyz.mapper;

import com.lyz.po.StockEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface StockMapper extends JpaRepository<StockEntity, Integer> {

    @Transactional
    @Modifying
    @Query("update StockEntity s set s.count=s.count-?2 where s.productId=?1")
    int updateCountByProductId(String productId, Integer count);
}
